<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<%@ taglib uri="/mytag" prefix="yjd"%>
<div class="wrap">
	<div class="nav">
		<div class="return">
			<a href='<yjd:url url="/org/all"/>'>返回上一页</a>
		</div>
	</div>
	<!-- start -->
	<form method="post" enctype="multipart/form-data" class="J_ajaxForm" autocomplete="off" action='<yjd:url url="/org/add/submit"/>'>
		<div class="table_full">
			<table width="100%">
				<tr>
					<th width="200">机构名称:</th>
					<td>
						<input name="org_name" type="text" class="input length_5" value="${org.org_name}">
						<input name="org_id" type="hidden" class="input length_5" value="${org.org_id}">
					</td>
				</tr>
				<tr>
					<th>机构图片:</th>
					<td>
						<input name="org_pic" type="hidden" class="input length_5" value="${org.org_pic}">
						<input name="org_imgfile" type="file" class="input length_5" >
						<c:if test="${org.strMap.org_pic != null}">(<a target="_black" href="${org.strMap.org_pic}">已经上传，点击查看</a>)</c:if>
					</td>
				</tr>
				<tr>
					<th width="200">主营业务:</th>
					<td><input name="org_major_business" type="text" class="input length_6" value="${org.org_major_business}" placeholder="多个用,隔开"></td>
				</tr>
				<tr>
					<th width="200">分期期数配置:</th>
					<td><input name="limit_config" type="text" class="input length_6" value="${org.limit_config}" placeholder="多个用,隔开"><label>例：[3,6,9,12]</label></td>
				</tr>
				<c:if test="${org.fund_channel > 0}">
					<tr>
						<th>资金渠道:</th>
						<td>
							<select name="fund_channel" id="fund_channel" class="mr10 length_2" >
								<option selected="selected" value="0">无</option>
								<c:forEach items="${fundChannelList }" var="item">
									<option ${item.fund_channel==org.fund_channel?"selected='selected'":"" } value="${item.fund_channel }">${item.name }</option>
								</c:forEach>
							</select>
						</td>
					</tr>
					<tr>
						<th width="200">机构收款户名:</th>
						<td><input name="payee_bank_account" type="text" class="input length_6" value="${org.payee_bank_account}" <c:if test="${not empty org.payee_bank_account}">disabled</c:if> ></td>
					</tr>
					<tr>
						<th width="200">机构收款银行卡号:</th>
						<td><input name="payee_bank_card" type="text" class="input length_6" value="${org.payee_bank_card}" <c:if test="${not empty org.payee_bank_card}">disabled</c:if> ></td>
					</tr>
				</c:if>
				<tr>
					<th>机构性质:</th>
					<td>
						<select name="org_type" id="org_type" class="mr10 length_2" >
							<c:forEach items="${orgTypeList }" var="item">
								<option ${item.key==org.org_type?"selected='selected'":"" } value="${item.key }">${item.value }</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<th>机构服务类型:</th>
					<td>
						<select name="service_type" id="service_type" class="mr10 length_2" >
							<c:forEach items="${serviceTypeList }" var="item">
								<option ${item.key==org.service_type?"selected='selected'":"" } value="${item.key }">${item.value }</option>
							</c:forEach>
						</select>
					</td>
				</tr>
				<tr>
					<th>机构城市:</th>
					<td>
						<select id="_sheng1" name="l1" onchange="selectChild('_sheng1','_shi1')">
							<option value="">请选择</option>
							<c:forEach items="${sheng_city }" var="sheng">
								<option value="${sheng.id }" <c:if test="${sheng.id == checked_hukou_sheng_id }">selected</c:if> >${sheng.name }</option>
							</c:forEach>
						</select>
						<select  id="_shi1" name="l2" onchange="selectChild('_shi1','city_id1')">
							<option value="">请选择</option>
						</select>
						<select id="city_id1" name="l3" onchange="$('#city1').val(this.value);">
							<option value="">请选择</option>
						</select>
						详细地址：<input id="address" name="org_address" type="text" maxlength="50" class="input length_5" value="" >
						<br/><c:if test="${org.strMap.org_address != null}">（原地址：${org.strMap.org_address})</c:if>
					</td>
				</tr>
				<tr>
					<th width="100">热搜标签：(建议不要超过5个标签)</th>
					<td colspan="2">
						<table>
							<c:forEach items="${tagModelList }" var="item" varStatus="status">
							<c:if test="${status.count==0}" >
							<tr>
								</c:if>
								<c:if test="${status.count%8==1}" >
							</tr><tr>
							</c:if>
							<td><input type="checkbox" value="${item.tag_id }" name="tags" <c:if test="${item.strMap.isCheck==true}">checked</c:if>>${item.tag_name }</input></td>
							</c:forEach>
						</table>
					</td>
				</tr>
				<tr>
					<th>机构电话:</th>
					<td><input name="org_tel_number" type="text" maxlength="50" class="input length_5" value="${org.org_tel_number}" ></td>
				</tr>
				<tr>
					<th>机构简介:</th>
					<td><textarea rows="5" cols="60" name="intro">${org.intro}</textarea></td>
				</tr>
				<tr>
					<th>机构详情:</th>
					<td>
						<input name="detail_id" type="hidden" class="input length_5" value="${org.detail_id}">
						<textarea name="detail" class="J_editor">${org.strMap.detail}</textarea>
					</td>
				</tr>
				<tr>
					<th>商户类型:</th>
					<td>
						<label><input name="org_mold" type="radio" value="1" <c:if test="${org.org_mold == 1}">checked</c:if> />普通</label>
						<label><input name="org_mold" type="radio" value="2" <c:if test="${org.org_mold == 2}">checked</c:if>/>VIP</label>
					</td>
				</tr>
                <c:if test="${org.org_mold == 2}">
					<tr>
						<th>还款利息分成比例（%）:</th>
						<td>
							<input name="interest_rate" type="text" class="input length_5" value="${org.interest_rate}">
						</td>
					</tr>
					<tr>
						<th>罚息分成比例（%）:</th>
						<td>
							<input name="overdue_rate" type="text" class="input length_5" value="${org.overdue_rate}">
						</td>
					</tr>
				   </c:if>
				<tr>
					<th>是否启用:</th>
					<td>
						<label><input name="is_used" type="radio" value="1" <c:if test="${org.is_used == 1}">checked</c:if>/>是</label>
						<label><input name="is_used" type="radio" value="0" <c:if test="${org.is_used == 0}">checked</c:if>/>否</label>
					</td>
				</tr>
				<tr>
					<th>是否推广:</th>
					<td>
						<label><input name="is_spread" type="radio" value="1" <c:if test="${org.is_spread == 1}">checked</c:if>/>是</label>
						<label><input name="is_spread" type="radio" value="0" <c:if test="${org.is_spread == 0}">checked</c:if> />否</label>
					</td>
				</tr>
			</table>
		</div>
		<input class="btn btn_submit J_ajax_submit_btn" type="submit" value="确认保存">
	</form>
</div>

<script>
    Upload_Config = {url : "${requestScope.FPWEB.rootPath }/resource/upload${requestScope.FPWEB.urlStuff}?type=1",uid : "${uid}",sign : "${sign}"};
    YJD.use('AppAdminCommon');

    var cityJson = ${cityJson};
    function selectChild(a,b){
        var hk_sheng = $("#"+a).val();
        var shi = selectChildList(hk_sheng);
        var temp="<option value=''>请选择</option>";
        for(i=0;i<shi.length;i++){
            var obj = shi[i];
            temp +="<option value="+obj.id+" >"+obj.name+"</option>";
        }
        $("#"+b).html(temp);
        if(b=='_shi'){
            $("#city_id").html("<option value=''>请选择</option>");
        }
        if(a=='_sheng1'){
            $("#_shi1").trigger("change");
        }
        if(a=='_sheng2'){
            $("#_shi2").trigger("change");
        }
    }

    function selectChildList(pid){
        var list = [];
        var length = cityJson.length;
        for(var i=0;i<length;i++){
            if(cityJson[i].parentid==pid){
                list.push(cityJson[i]);
            }
        }
        return list;
    }

</script>
